/**select validate*/
$.extend($.fn.validatebox.defaults.rules, {
    cantSelect: {
        validator: function(value, param){
			return value != param[0];
        },
        message: '请选择对应值.'
    }
});

/**add same validate*/
$.extend($.fn.validatebox.defaults.rules, {
    same: {
        validator: function(value, param){
			return value == $('#' + param[0]).val();
        },
        message: '请输入相同的值.'
    }
});
/**isint[0] 大于0的数*/
$.extend($.fn.validatebox.defaults.rules, {
    isint: {
        validator: function(value, param){
			try{
				if( value.lastIndexOf( "." ) > -1 ) return false;
				var temp = parseInt( value );
				if( temp != temp ) return false;
				var flag = true;
				if( param[0] != undefined){
					flag = value >= parseInt( param[0] );
				}
				if( param[1] != undefined ){
					flag = value <= parseInt( param[1] );
				}
				return flag;
			}catch(e){
				return false;
			}
        },
        message: '请输入整数值.'
    }
});

/**isfloat[0] 大于0的数*/
$.extend($.fn.validatebox.defaults.rules, {
    isfloat: {
        validator: function(value, param){
			try{
				var temp = parseFloat( value );
				if( temp != temp ) return false;
				var flag = true;
				if( param[0] != undefined){
					flag = value >= parseFloat( param[0] );
				}
				if( param[1] != undefined ){
					flag = value <= parseFloat( param[1] );
				}
				return flag;
			}catch(e){
				return false;
			}
        },
        message: '请输入小数值.'
    }
});

/**email and length*/
$.extend($.fn.validatebox.defaults.rules, {
    emailandlength: {
        validator: function(value, param){
			var rules = $.fn.validatebox.defaults.rules;
			try{
				return rules.email["validator"](value) && rules.length["validator"]( value , param );
			}catch(e){
				alert(e);
			}
			
        },
        message: 'Please enter a same char with {0}.'
    }
});
/**checkbox checked */
$.extend($.fn.validatebox.defaults.rules, {
    checked: {
        validator: function(value, param){
			var rules = $.fn.validatebox.defaults.rules;
			try{
				return rules.email["validator"](value) && rules.length["validator"]( value , param );
			}catch(e){
				alert(e);
			}
			
        },
        message: 'Please enter a same char with {0}.'
    }
});
function ischecked( ele , length , msg ){
	flag = false;
	ele.each(function(){
		if( $(this).attr("checked") == true ){
			flag = true;
		}
	});
	$(ele).parent().children("#errorMsg").html('');
	if( !flag ){
		$(ele[ele.length-1]).parent().append( "<font class='error' id='errorMsg'>" + msg + "</font>" );
	}
	ele.click(function(){
		if( $(this).attr("checked") ){
			$(this).parent().children("#errorMsg").html('');
		}
	});
	return flag;
}